<template>
	<view class="contents">
		<view class="oredr_list">
			<view class="order_head">
				<view class="order">
					订单编号：{{order_no}}
				</view>

			</view>
			<view class="order_content">
				<view class="order_img">
					<image :src="orderdetail.image" mode=""></image>
				</view>
				<view class="order_text">
					<view class="order_title">
						{{orderdetail.store_name}}
					</view>
					<view class="order_detail">
						{{orderdetail.unit_name}}
					</view>
					<view class="order_tab">
						<view class="tab_list" v-for="(item,index) in 1" :key="index">
							特惠
						</view>
					</view>
					<view class="order_price">
						<view class="spellgroup">
							<view class="new_price">
								￥{{orderdetail.price}}
							</view>
							<view class="tab_list" v-for="(item,index) in 1" :key="index">
								礼物
							</view>
						</view>

						<view class="old_price">
							￥{{orderdetail.ot_price}}
						</view>
					</view>

				</view>
			</view>
		</view>
		<view class="send_to_receive" v-if="wlInfo.list.length>1">
			<view class="send">
				{{seller_address}}
			</view>
			<view class="transfer_station">
				<view class="top">
					<image src="../../static/shouji1.png" mode=""></image>
					<image src="../../static/wuliu1.png" mode=""></image>
					<image src="../../static/shouji.png" mode=""></image>
				</view>
				<view class="mid">
					<view class="left" v-for="item in 12" :key="index">
						<view class="active">
						</view>
					</view>
					<view class="right" v-for="item in 10" :key="index">
						<view class="">

						</view>
					</view>
				</view>

				<view class="bot">
					<view class="send_time">
						{{wlInfo.list[wlInfo.list.length-1].time.slice(5,10)}}
					</view>
					<view class="station_name">
						<!-- 湖南中转站 -->
					</view>
					<view class="receive_time">
						<!-- 预计送达时间 -->
					</view>
				</view>
			</view>
			<view class="receive">
				{{user_address.split(' ')[1]}}
			</view>

		</view>
		<view class="logistics_details" v-if="wlInfo.list.length>1">
			<view class="courier">
				<view class="left">
					<view class="round"></view>
					<view class="info">
						<text>{{delivery_name}}:</text><text>{{delivery_id}}</text>
					</view>
				</view>
				<view class="right"></view>
			</view>

			<xinyu-logistics :wlInfo="wlInfo"></xinyu-logistics>
		</view>
		<view style="text-align: center;color: #999;margin-top: 20rpx;" v-if="wlInfo.list.length<=1">
			暂无详细物流信息
		</view>
		
	</view>
</template>

<script>
	import {
		orderDetail,
		checkLogistics
	} from '@/api/api.js'
	export default {
		data() {
			return {
				order_no: '', //订单号
				delivery_id: '', //物流单号
				delivery_name: '', //物流公司
				seller_address: '', //发货地址
				user_address: '', //收货地址
				orderdetail: {}, //订单详情
				data:'',
				// 物流信息
				wlInfo: {
					post_no: '',
					delivery_status: 1, //快递状态 1已签收 2配送中
					list: [{
						"time": "",
						"status": ""
					}]
				}
			}
		},
		onLoad(options) {
			this.wlInfo.post_no = options.id
			// console.log('options.id',this.wlInfo.post_no)
			let data = `uni=${this.wlInfo.post_no}`
			orderDetail(data).then(res => {
				console.log('订单详情',res)
				if (res.data.code == '200') {
					this.order_no = res.data.data.order[0].order_id
					this.orderdetail = res.data.data.order[0].cartInfo[0].productInfo
					this.user_address = res.data.data.order[0].user_address
					if (res.data.data.order[0].delivery_id == '' || res.data.data.order[0].delivery_id == null) {
						return
					}
					if (res.data.data.order[0].delivery_id) {
						this.delivery_name = res.data.data.order[0].delivery_name
						this.delivery_id = res.data.data.order[0].delivery_id
						this.checkLogistics()
					}
					if (res.data.data.suppliers.id > 0) {
						this.seller_address = res.data.data.suppliers.city
						console.log('发货地址:',this.seller_address)
					}
					if (res.data.data.suppliers.id == 0 || res.data.data.suppliers.id == '' || !res.data.data.suppliers.id) {
						this.seller_address = res.data.data.address.site_city
						console.log('发货地址:',this.seller_address)
					}
					
				}
			})

		},
		methods: {
			// 物流信息
			checkLogistics() {
				let data = `delivery_id=${this.delivery_id}`
				checkLogistics(data).then(res => {
					console.log('物流信息:',res)
					if (res.data.code == '200' && res.data.data.content) {
						    // console.log('物流',res.data.data.content)
							this.wlInfo.list = res.data.data.content
						    this.data = res.data
					}
					// console.log(this.wlInfo.list)
				})
			}
		}
	}
</script>

<style lang="scss">
	.contents {
		width: 100%;
		min-height: 100vh;
		background-color: rgb(247, 249, 252);
		margin: 0 auto;

		.oredr_list {
			width: 694rpx;
			// height: 456rpx;
			background-color: #fff;
			border-radius: 10rpx;
			margin: 0 auto;
			padding-bottom: 40rpx;

			.order_head {
				box-sizing: border-box;
				padding: 0 28rpx;
				width: 100%;
				height: 80rpx;
				line-height: 80rpx;
				display: flex;
				justify-content: space-between;
				font-size: 26rpx;

				.order {
					color: #999999;
				}

				.status {
					color: #D41312;
				}
			}

			.order_content {
				box-sizing: border-box;
				padding: 0 28rpx;
				width: 100%;
				height: 182rpx;
				display: flex;

				.order_img {
					width: 182rpx;
					height: 182rpx;
					flex-shrink: 0;

					image {
						border-radius: 8rpx;
						width: 100%;
						height: 100%;
					}
				}

				.order_text {
					margin-left: 30rpx;
					width: 470rpx;

					.order_title {
						width: 100%;
						height: 40rpx;
						line-height: 40rpx;
						font-size: 30rpx;
						color: #333;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
						-o-text-overflow: ellipsis;
					}

					.order_detail {
						margin-top: 10rpx;
						width: 470rpx;
						height: 40rpx;
						line-height: 40rpx;
						font-size: 26rpx;
						color: #999999;
						text-overflow: ellipsis;
						white-space: nowrap;
						overflow: hidden;
					}

					.order_tab {
						margin-top: 15rpx;
						width: 100%;
						height: 30rpx;
						line-height: 30rpx;
						font-size: 26rpx;
						display: flex;

						.tab_list {
							width: 56rpx;
							height: 32rpx;
							background-color: rgb(255, 234, 234);
							color: rgb(255, 45, 45);
							font-size: 20rpx;
							text-align: center;
							line-height: 32rpx;
							margin-right: 20rpx;
							border-radius: 6rpx;
						}
					}

					.order_price {
						margin-top: 10rpx;
						width: 100%;
						height: 30rpx;
						line-height: 30rpx;
						font-size: 26rpx;

						.spellgroup {
							display: flex;

							.new_price {
								color: #3DB963;
								font-size: 24rpx;
								margin-right: 20rpx;
							}

							.tab_list {
								// width: 56rpx;
								height: 32rpx;
								background-color: rgb(61, 185, 99);
								color: rgb(255, 255, 255);
								font-size: 20rpx;
								text-align: center;
								line-height: 32rpx;
								padding: 0 12rpx;
								border-radius: 6rpx;
							}
						}

						.old_price {
							color: #999999;
							font-size: 22rpx;
							text-decoration: line-through;
							margin-left: 6rpx;
						}

					}
				}
			}

			.fengexian {
				width: 640rpx;
				border: 1rpx solid #EEEEEE;
				margin: 30rpx auto 0;
			}

			.order_time {
				box-sizing: border-box;
				padding: 0 28rpx;
				width: 100%;
				height: 30rpx;
				line-height: 30rpx;
				display: flex;
				justify-content: space-between;
				font-size: 26rpx;
				margin-top: 20rpx;
				color: #999999;
				font-size: 26rpx;

				span {
					color: #3DB963;
				}
			}

			.order_bottom {
				width: 100%;
				display: flex;
				margin-top: 25rpx;

			}

		}

		.send_to_receive {
			box-sizing: border-box;
			width: 694rpx;
			background-color: #fff;
			border-radius: 10rpx;
			margin: 18rpx 28rpx 18rpx;
			padding: 36rpx 28rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;

			.send,
			.receive {
				text-align: center;
				width: 140rpx;
				font-size: 36rpx;
				font-weight: 600;
				overflow: hidden;
				-o-text-overflow: ellipsis;
				-webkit-line-clamp: 1;
				-webkit-box-orient: vertical;
				display: -webkit-box;
			}

			.transfer_station {
				// display: flex;
				// align-items: center;
				width: 400rpx;
				overflow: hidden;
				flex: 1;

				.top {
					display: flex;
					justify-content: space-between;

					image {
						width: 60rpx;
						height: 60rpx;
					}
				}

				.mid {
					display: flex;

					>view {
						display: flex;
						height: 10rpx;
						width: 50%;

						>view {
							height: 10rpx;
							width: 10rpx;
							background-color: #999;
							border-radius: 5rpx;

							&.active {
								background-color: #3DB963;
							}
						}
					}

				}

				.bot {
					display: flex;
					justify-content: space-between;
					font-size: 24rpx;
					color: #999999;
				}
			}
		}

		.logistics_details {
			width: 694rpx;
			margin: 0 auto;
			background-color: #fff;
			padding-top: 12rpx;
			border-radius: 10rpx;

			.courier {
				display: flex;
				justify-content: space-between;
				margin: 0 28rpx;
				padding: 28rpx 0;
				border-bottom: 2rpx dotted #999999;

				.left {
					display: flex;

					.round {
						width: 48rpx;
						height: 48rpx;
						border-radius: 24rpx;
						background-color: #3DB963;
						margin-right: 24rpx;
					}
				}

				.right {
					width: 48rpx;
					height: 48rpx;
					border-radius: 24rpx;
					box-sizing: border-box;
					border: 2rpx solid #3DB963;
				}
			}
		}
	}
</style>
